<template>
    <div class="icons">
        <swiper :options="swiperOption">
            <swiper-slide v-for="(page,index) of iconPage" :key="index">
                <div class="icon" v-for="item of page" :key="item.id">
                    <div class="icon-image"><img width="100%" height="95%" :src="item.imgUrl" /></div>
                    <p class="icon-content">{{ item.desc }}</p>
                </div>
            </swiper-slide>
        </swiper>
    </div>
</template>

<script type="text/ecmascript-6">
import {$iconlist} from '../../../assets/js/common.js'
export default{
   props:{
     iconList:{
        type:Array
     }
   },
    data(){
        return{
            swiperOption:{
               setWrapperSize :true,
               mousewheelControl : true,
            }
        }
    },
    computed:{
        iconPage(){
            const pages= [];
            this.iconList.forEach((item,index) => {
                const page = Math.floor(index/8)
                if(!pages[page]){
                    pages[page]=[]
                }
                pages[page].push(item)
            })
            return pages
        }
    }
}
</script>

<style lang="stylus" rel="stylesheet/stylus">
.icons
    margin-top 10px
    overflow hidden
    width 100%
    height 0
    padding-bottom 50%
    .icon
        position relative
        float left
        width 25%
        height 0
        padding-bottom 25%
        .icon-image
            position absolute
            top 5px
            left 0
            right 0
            bottom 22px
            width 76%
            margin 0 auto
            box-sizing border-box
            overflow hidden
        .icon-content
            position absolute
            right 0
            left 0
            bottom 6px
            color #333
            text-align center
            font-size 12px
            overflow hidden
            white-space nowrap
            text-overflow ellipsis
</style>
